import { BaseViteConfig } from '@ac/vite-config';
import { defineConfig, loadEnv, mergeConfig } from 'vite';
import { name } from './package.json';

export default ({ mode }: any) => {
	const env = loadEnv(mode, process.cwd());
	console.log(name, env);
	return defineConfig(
		mergeConfig(BaseViteConfig(__dirname), {
			server: {
				port: 8088,
				host: '0.0.0.0',
				// 允许跨域
				cors: true,
				// 自动打开浏览器
				open: false
			},
			build: {
				assetsInlineLimit: 8 * 1024, // 8kb
				rollupOptions: {
					output: {
						manualChunks: {
							'vendor-react': ['react', 'react-dom'],
							'vendor-antd': ['antd'],
							'vendor-router': ['react-router-dom']
						}
					}
				}
			}
		})
	);
};
